package com.java.threaddemo1;

import java.util.Scanner;

public class TestDriver {
	public static void main(String[] args) {
		test01();
	}

	private static void test01() {

		// 创建一个仓库
		WarehouseStack whStack = new WarehouseStack();
		// 创建一个生产者
		Producter producter = new Producter(whStack);
		// 创建一个消费者
		Runnable r = new Consumer(whStack);
		Thread consumer = new Thread(r);
		producter.start();
		consumer.start();

		// 从控制台输入能够终止程序
		Scanner sc = new Scanner(System.in);
		System.out.println("若想结束生产者程序，请输入【s】:");
		String str1 = sc.next();
		if (str1.trim().equalsIgnoreCase("s")) {
			producter.setStopped(true);
		}
		System.out.println("生产者程序结束！");

	
	}
}
